package demo.practice.tree;

public class P240 {

    public boolean searchMatrix(int[][] matrix, int target) {
        int w = matrix[0].length;
        int i = matrix.length - 1;
        int j = 0;

        while (j < w && i >= 0) {
            if (matrix[i][j] == target) {
                return true;
            } else if (matrix[i][j] > target) {
                i--;
            } else {
                j++;
            }
        }
        return false;
    }
}
